package cn.zhx.domain.strategy.event;

import cn.zhx.domain.strategy.model.valobj.StrategyAwardStockKeyVO;
import cn.zhx.types.event.BaseEvent;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author: zhx
 * @Date: 2024/07/15
 * @Description: 策略奖品库存为0
 **/

@Component
public class StrategyAwardStockZeroMessage extends BaseEvent<StrategyAwardStockKeyVO> {

    @Value("${spring.rabbitmq.topic.strategy_award_stock_zero}")
    private String topic;

    @Override
    public EventMessage<StrategyAwardStockKeyVO> buildEventMessage(StrategyAwardStockKeyVO strategyAwardStockKeyVO) {
        return EventMessage.<StrategyAwardStockKeyVO>builder().id(RandomStringUtils.randomNumeric(11))
                .timestamp(new Date())
                .data(strategyAwardStockKeyVO).build();
    }

    @Override
    public String topic() {
        return topic;
    }
}
